Skipping image name at start of command line is an
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 29 Aug 2007 14:43:53 +0000 (15:43 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 29 Aug 2007 14:43:53 +0000 (15:43 +0100)
architecture-specific action. Definitely not required on IA64, for now
make it just x86 specific.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/setup.c
xen/common/kernel.c

index 7998612653d34250157c6d6f24632901285e4885..3a6c3d7a6a4f006ffd6e076725e175c9c4a40bfc 100644 (file)
@@ -429,10 +429,22 @@ void init_done(void)
     startup_cpu_idle_loop();
 }
 
+static char * __init cmdline_cook(char *p)
+{
+    p = p ? : "";
+    while ( *p == ' ' )
+        p++;
+    while ( (*p != ' ') && (*p != '\0') )
+        p++;
+    while ( *p == ' ' )
+        p++;
+    return p;
+}
+
 void __init __start_xen(unsigned long mbi_p)
 {
     char *memmap_type = NULL;
-    char __cmdline[] = "", *cmdline = __cmdline, *kextra;
+    char *cmdline, *kextra;
     unsigned long _initrd_start = 0, _initrd_len = 0;
     unsigned int initrdidx = 1;
     char *_policy_start = NULL;
@@ -451,8 +463,8 @@ void __init __start_xen(unsigned long mbi_p)
     set_intr_gate(TRAP_page_fault, &early_page_fault);
 
     /* Parse the command-line options. */
-    if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0) )
-        cmdline = __va(mbi->cmdline);
+    cmdline = cmdline_cook((mbi->flags & MBI_CMDLINE) ?
+                           __va(mbi->cmdline) : NULL);
     if ( (kextra = strstr(cmdline, " -- ")) != NULL )
     {
         /*
@@ -1037,18 +1049,8 @@ void __init __start_xen(unsigned long mbi_p)
     {
         static char dom0_cmdline[MAX_GUEST_CMDLINE];
 
-        dom0_cmdline[0] = '\0';
-
-        if ( cmdline != NULL )
-        {
-            /* Skip past the image name and copy to a local buffer. */
-            while ( *cmdline == ' ' ) cmdline++;
-            if ( (cmdline = strchr(cmdline, ' ')) != NULL )
-            {
-                while ( *cmdline == ' ' ) cmdline++;
-                safe_strcpy(dom0_cmdline, cmdline);
-            }
-        }
+        cmdline = cmdline_cook(cmdline);
+        safe_strcpy(dom0_cmdline, cmdline);
 
         if ( kextra != NULL )
             /* kextra always includes exactly one leading space. */
index 117690461ff9f5a62b2d2068027e3cfcda65fc34..9bfba6b949ccaca7d3f557a3b520f97bd0af059d 100644 (file)
@@ -34,12 +34,6 @@ void cmdline_parse(char *cmdline)
     if ( p == NULL )
         return;
 
-    /* Skip whitespace and the image name. */
-    while ( *p == ' ' )
-        p++;
-    if ( (p = strchr(p, ' ')) == NULL )
-        return;
-
     for ( ; ; )
     {
         /* Skip whitespace. */